package top.zuli.package03.exam01;

public class StaticProxyDemo {
    public static void main(String[] args) {
        User user = new UserImpl();
        user.add("张三");
        user.del("1");
        User proxyUser = new UserProxy(user);
        proxyUser.add("李四");
        proxyUser.del("2");
    }
}
//1.接口定义规范
interface User {
    //1.添加用户数据
    public void add(String data);
    //2.根据id删除用户
    public void del(String id);
}
//2.被代理类
class UserImpl implements User{

    @Override
    public void add(String data) {
        System.out.println("添加"+data+"据");
    }

    @Override
    public void del(String id) {
        System.out.println("根据"+id+"删除数据");
    }

}
//3.代理类
class UserProxy implements User{
    private User user;


    public UserProxy(User user) {
        this.user = user;
    }

    @Override
    public void add(String data) {
        user.add(data);
        System.out.println("日志信息");
    }

    @Override
    public void del(String id) {
        user.del(id);
        System.out.println("日志信息");
    }

}